package com.qf.house.controller;


import com.qf.house.entity.House;
import com.qf.house.entity.SearchParams;
import com.qf.house.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房屋信息表(House)表控制层 12312312312312313
 *
 * @author makejava
 * @since 2024-01-09 14:40:43
 */
@RestController
@RequestMapping("/house")
@CrossOrigin
public class HouseController {

    @Autowired
    private HouseService houseService;

    /**
     * 新增房屋信息
     * @param house
     * @return
     */
    @PostMapping("/insert")
    public int insert(@RequestBody House house) {
        System.out.println("添加房屋信息：" + house);
        houseService.save(house);
        return 1;
    }

    /**
     * 搜索房屋信息
     * 关键词（标题、描述、小区、城市）
     * 价格范围
     * 几室几厅
     * @return
     */
    @PostMapping("/search")
    public List<House> search(@RequestBody SearchParams searchParams){
        return houseService.searchHouse(searchParams);
    }

    /**
     * 删除房屋信息12112123123
     * @return
     */
    @PostMapping("/delete")
    public int deleteHouseById(){
        return 1;
    }

    /**
     * 更新房屋信息
     * @return
     */
    @PostMapping("/update")
    public int updateHouse(){
        return 1;
    }
}

